package com.itlong.cloud.property.service.impl;

import com.itlong.cloud.POJO.DTO.property.PropertyAmountChangeGetPageDTO;
import com.itlong.cloud.POJO.VO.property.PropertyAmountChangeGetPageVO;
import com.itlong.cloud.property.dao.IPropertyAmountChangeDao;
import com.itlong.cloud.property.service.IPropertyAmountChangeService;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      物业-资金变动明细服务接口实现类
 * <desc/>
 *
 * @createDate 2018/09/25
 */
@Service
public class PropertyAmountChangeServiceImpl implements IPropertyAmountChangeService {

    @Autowired
    private IPropertyAmountChangeDao iPropertyAmountChangeDao;

    /**
     * <desc>
     *      分页获取资金变动明细
     * </desc>
     *
     * @param propertyAmountChangeGetPageDTO 物业-资金变动明细列表查询DTO
     * @return 标准格式化响应结果
     * @author wangzhi
     * @createDate 2018/09/25
     */
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Page<PropertyAmountChangeGetPageVO> getAmountChangeByPage(PropertyAmountChangeGetPageDTO propertyAmountChangeGetPageDTO) throws Exception {
        Map<String,Object> params = SqlUtil.convertBeanToMapParams(propertyAmountChangeGetPageDTO);
        Page<PropertyAmountChangeGetPageVO> page = new Page<>();
        page.getPage().setPageSize(propertyAmountChangeGetPageDTO.getPageSize());
        page.getPage().setCurrentPage(propertyAmountChangeGetPageDTO.getCurrentPage());
        params.put("startSlip", page.getPage().getStartSlip());
        params.put("pageSize", page.getPage().getPageSize());
        List<PropertyAmountChangeGetPageVO> operateGetProjectFinancePageVOS = iPropertyAmountChangeDao.getAmountChangePage(params);
        page.setRows(operateGetProjectFinancePageVOS,iPropertyAmountChangeDao.getAmountChangeRecordCount(params));
        return page;
    }
}
